<template>
  <div>
    <!-- 把需要的属性值 通过父传子 传过去 -->
    <MyHeader title="鬼市案例" color="red" bgc="green"></MyHeader>
    <div class="main">
      <MyGoods v-for="item in list" :key="item.id" :good="item"></MyGoods>
    </div>
    <MyFooter :list="list"></MyFooter>
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader";
import MyGoods from "./components/MyGoods";
import MyFooter from "./components/MyFooter";
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter,
  },
  data() {
    return {
      // 商品所有数据
      list: [],
    };
  },
  // 不必在自己引入axios变量, 而是直接使用全局属性$axios
  created() {
    this.$axios({
      url: "/api/cart",
    })
    // 接数据 接的是res里面data里面的list 并把值赋值给list
      .then((res) => 
     this.list = res.data.list)
      .catch((err) => console.log(err));
  },
};
</script>

<style>
.main {
  padding-top: 45px;
  padding-bottom: 50px;
}
</style>